<template>
  <div class="data-count-cost-detail">
    <el-row :gutter="10">
      <el-col :span="24">
        <el-card class="box-card">
          <!-- 头部 -->
          <div slot="header" class="clearfix fix-lh">
            <span>{{$route.query.start}}--{{$route.query.end}}&nbsp;&nbsp;&nbsp;&nbsp;包时课程扣费明细</span>
          </div>
          <div class="home-body">
            <cvue-table
              :option="tableOption"
              :data="tableData"
              ref="tbl1"
              :isShowAdd="false"
              :page="page"
              :tablePage="tablePage"
              :pageSize="page.pageSize"
              :loading="tableLoading"
              @current-change="handleCurrentChange"
              @size-change="handleSizeChange"
              :isShowPage="false">
              <template slot-scope="scope" slot="usedMoney">
                <span>{{ scope.row.usedMoney == '-' ? scope.row.usedMoney : (scope.row.usedMoney/100).toFixed(2) }}</span>
              </template>
            </cvue-table>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
/* eslint-disable */
import cvueTable from '@/components/cvue-table'
export default {
  name: 'data-count-cost-detail',
  components: {
    cvueTable
  },
  data () {
    return {
      tablePage: 1,
      tableLoading: false,
      page: {
        total: 1, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10, // 每页显示多少条
        pageSizes: [10, 50, 100]
      },
      tableOption: {
        stripe: true,
        width: '100%',
        border: true,
        index: false,
        selected: false,
        cloumn: [
          { prop: 'index', label: '', align: 'center', width: 58 },
          { prop: 'courseName', label: '课程名称', align: 'center', sortable: true },
          { prop: 'userMemberNames', label: '会员名称', align: 'center', sortable: true },
          { prop: 'userMemberPhones', label: '会员手机号', align: 'center', sortable: true },
          { prop: 'coachUserName', label: '关联教练', align: 'center', sortable: true },
          { prop: 'calculateTime', label: '触发扣费日期', align: 'center', sortable: true },
          { prop: 'usedMoney', label: '扣款金额(元)', align: 'center', sortable: true, slotStatus: true },
          { prop: 'appointmentCount', label: '该扣费周期耗课节数', align: 'center' }
        ]
      },
      tableData: [
        // { name: 'ddd', code: 'sss', order: 1, status: 1 }
      ],
      dialogIndexEdit: false,
      actionType: 'add',
      rowData: {},
      courseModeArr: [],
      courseStateArr: [],
      courseTypeArr: [],
      saleModeArr: [],
      coachArr: [],
      ruleForm: {
        saleMode: '',
        coachUserId: '',
        key: ''
      },
      selectForm: {
        saleMode: '',
        coachUserId: '',
        key: ''
      },
      signCourseStateArr: []
    }
  },
  created () {
    this.getDic().then(res => {
      this.dict = res.data
      this.dict.forEach((item, index) => {
        if (item.dicName == 'CourseMode') {
          this.courseModeArr = item.dicValueList
        }
      })
    })
  },
  activated () {
    this.handleList()
  },
  methods: {
    // 改变pagesize
    handleSizeChange (val) {
      this.page.pageSize = val
      this.handleList()
    },
    // 改变页码
    handleCurrentChange (val) {
      this.tablePage = val
      this.handleList()
    },
    // 列表接口
    handleList () {
      this.tableLoading = true
      var params = {
        "end": this.$route.query.end,
        "start": this.$route.query.start,
      }
      this.$store.dispatch('manage/SelectPrivateTimesUsedDetail', params).then(res => {
        // console.log(res)
        if (res.code=='200') {
          var data = res.data
          this.tableData = data
          // this.page.total = parseInt(res.data.total)
          // this.page.currentPage = this.tablePage
        }
        this.tableLoading = false
      }).catch(err => {
        console.log(err)
        this.tableLoading = false
      })
    },
    // 关闭弹窗
    closeDialog (params) {
      if (params == 'edit') {
        this.dialogIndexEdit = false
      }
    },
    // 确认
    confirmDialog (params) {
      if (params == 'edit') {
        this.dialogIndexEdit = false
      }
    },
    handleSearch () {
      this.tablePage = 1
      this.handleList()
    }
  }
}
</script>

<style lang="scss">
.data-count-cost-detail {
  padding: 0px !important;
  height: auto !important;
  .btn-list {
    float: right;
    margin-right: 10px;
    font-size: 12px;
    color: #409EFF;
    cursor: pointer;
  }
  .el-card__header {
    border-bottom: none;
  }
  .el-card__header,
  .el-card__body {
    padding: 15px;
  }
  .fix-lh {
    line-height: 32px;
  }
  .el-input.is-disabled .el-input__inner {
    color: #606266;
  }
  .left{
    min-height:500px;
    background:#fff;
  }
  .left-tree{
    width: 100%;
    min-height:600px;
    overflow: auto;
  }
  .left-top{
    width: 100%;
    height: 40px;
    text-align: center;
    line-height: 40px;
    font-size: 16px;
    color: #333;
    background: #e2e2e2;
    font-size: 15px;
  }
}
</style>
